﻿
namespace Sai.Test.Introspection
{
    using Sai.Core;
    using Sai.Test.TestDataBuilders;
    using Sai.Test.XUnit;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Xunit;

    public class PropertyDeclarationFacts
    {
        public class TheToCodeMethod
        {
            
            [Fact, InMemoryTest]
            public void Returns_Type_Name_Get_And_Set()
            {
                var property = PropertyDeclarationBuilder.Property()
                    .Named("Amount")
                    .OfType("double")
                    .WithPublicGetter()
                    .WithPublicSetter()
                    .InClass("Calculator")
                    .Build();

                SourceCode code = property.ToCode();

                Assert.Equal(6, code.Content.Count);
                Assert.Equal("tn", code.Content[0].Name);
                Assert.Equal("double", code.Content[0].Value);
                Assert.Equal("ident", code.Content[1].Name);
                Assert.Equal("Amount", code.Content[1].Value);
                Assert.Equal("punc", code.Content[2].Name);
                Assert.Equal("{", code.Content[2].Value);
                Assert.Equal("kw", code.Content[3].Name);
                Assert.Equal("get;", code.Content[3].Value);
                Assert.Equal("kw", code.Content[4].Name);
                Assert.Equal("set;", code.Content[4].Value);
                Assert.Equal("punc", code.Content[5].Name);
                Assert.Equal("}", code.Content[5].Value);

            }
        }

    }
}
